<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../common/mui/mui.min.css" rel="stylesheet" />
		<link href="../../common/mui/mui.picker.min.css" rel="stylesheet" />
		<link href="../../common/mui/mui.poppicker.css" rel="stylesheet" />
		<link href="../../common/css/xhPicker.css" rel="stylesheet" />
		<style type="text/css">
			.mui-backdrop{
				background: transparent;
				display: none;
			}
			html,body{
				background: white;
			}
		</style>
	</head>

	<body>
		<script src="../../common/mui/mui.js"></script>
		<script src="../../common/mui/mui.picker.min.js"></script>
		<script src="../../common/mui/mui.poppicker.js"></script>
		<script src="../../common/js/xhPicker.js"></script>
		<script type="text/javascript">
			var dtpicker,nextDay;
			var self
			mui.init({
				swipeBack: false
			});
			mui.plusReady(function(){
				self = plus.webview.currentWebview();
				nextDay = self.nextDay
				var endDay = nextDay.replace(/-/g,'/');
				if (plus.os.name == 'iOS') {
					//iOSSetup(endDay)
				}else{
					androidSetup(endDay)
				}
				mui.back = function() {
					var operationP = plus.webview.getWebviewById('../WKPlatformPages/operation/operationP.html');
					if (operationP) {
						operationP.evalJS('backEvent()')
					}
				}
			});
			function androidSetup(endDay){
				dtpicker = new mui.DtPicker({
				    type: "date",//设置日历初始视图模式 
				    endDate: new Date(endDay),
					value:nextDay
				}) 
				pickerShow();
				mui('body').on('tap','.mui-dtpicker-header > button',function(e){
					var self = plus.webview.currentWebview();
					self.hide()
				});
				mui("body").on("tap",".mui-backdrop",function(){
					var self = plus.webview.currentWebview();
					self.hide()
				})
			}
			function pickerShow(){
				if (plus.os.name == 'iOS'){
					var endDay = nextDay.replace(/-/g,'/');
					plus.nativeUI.pickDate(function(e) {
						self.hide()
						var d = e.date;
						var dateStr = d.getFullYear()+'-'
						if (d.getMonth() < 9) {
							dateStr += '0'
						}
						dateStr += (d.getMonth() + 1)+'-'
						if (d.getDate() < 10) {
							dateStr += '0'
						}
						dateStr += d.getDate()
						var hours = new Date().getHours();
						if (hours < 12 && dateStr == nextDay) {
							mui.toast('次日手术请在12:00后查询！')
							return
						}
						var operationP = plus.webview.getWebviewById('operationP.html');
						operationP.evalJS('changeDate("'+dateStr+'")')
					}, function(e) {
						self.hide()
					}, {
						title: "",
						maxDate: new Date(endDay)
					});
				}else{
					dtpicker.show(function(rs) {
						var hours = new Date().getHours();
						if (hours < 12 && rs.text == nextDay) {
							mui.toast('次日手术请在12:00后查询！')
							return
						}
					    var operationP = plus.webview.getWebviewById('../WKPlatformPages/operation/operationP.html');
					    operationP.evalJS('changeDate("'+rs.text+'")')
					});
				}
			}
		</script>
	</body>

</html>